﻿using System;
using Microsoft.Xna.Framework;
using CellarDoor.Gui.Elements;

namespace CellarDoor.Gui.Animation
{
    public class AnimateColor : AnimateComponent
    {
        /// <summary>
        /// The start color
        /// </summary>
        public Vector3 StartColor { get; set; }

        /// <summary>
        /// The end color
        /// </summary>
        public Vector3 EndColor { get; set; }

        public bool SetR { get; set; }
        public bool SetG { get; set; }
        public bool SetB { get; set; }

        public AnimateColor(UiElement element)
            : base(element)
        {
            SetR = true;
            SetG = true;
            SetB = true;
        }

        protected override void Animate()
        {
            Vector3 color = StartColor + (EndColor - StartColor) * EasedProgress;
            if (!SetR)
                color.X = Target.Color.X;
            if (!SetG)
                color.Y = Target.Color.Y;
            if (!SetB)
                color.Z = Target.Color.Z;
            Target.Color = color;
        }
    }
}
